package com.xpgk.mvc.ddc.maintenance.vehicleInformation;

import com.jfinal.aop.Before;
import com.jfinal.plugin.activerecord.tx.Tx;
import com.xpgk.dto.RenderBean;
import com.xpgk.mvc.base.BaseController;

public class VehicleInformationController extends BaseController{

	private VehicleInformationService vehicleInformationService;
	public void index(){
		render("vehicleInformation.html");
	}
	
	/**
	 * 车牌列表
	 */
	public void vehicleList(){
		String json = paging(splitPage, VehicleInformation.sqlId_splitPageSelect, VehicleInformation.sqlId_splitPageFrom);
		renderJson(json);
	}
	
	/**
	 * 跳转至添加产品
	 */
	public void toAddVehicle(){
		render("addVehicle.html");
	}
	
	/**
	 * 添加产品
	 */
	public void addVehicle(){
		VehicleInformation vehicleInformation = getModel(VehicleInformation.class);
		RenderBean renderBean = vehicleInformationService.addVehicle(vehicleInformation);
		renderJson(renderBean);
	}
	
	/**
	 * 跳转至编辑
	 */
	public void toUpVehicle(){
		VehicleInformation vehicleInformation = VehicleInformation.dao.findById(ids);
		setAttr("vehicleInformation", vehicleInformation);
		render("upVehicle.html");
	}
	
	/**
	 * 编辑
	 */
	public void upVehicle(){
		
		VehicleInformation vehicleInformation = getModel(VehicleInformation.class);
		RenderBean renderBean = vehicleInformationService.upVehicle(vehicleInformation);
		renderJson(renderBean);
	}
	
	/*
	 * 更该产品状态
	 */
	@Before(Tx.class)
	public void vehicleListstruts(){
		String ids = getPara("ids");
		VehicleInformation vehicleInformation = VehicleInformation.dao.findById(ids);
		vehicleInformation.set(VehicleInformation.column_dataStatus,"0");
		boolean result = vehicleInformation.update();
		renderJson(result);
	}

}
